package com.example.mybatisdemo.util;

/**
 * TODO
 *
 * @Description: TODO
 * @author: liuyingj@new-di.com
 * @date: 2019年08月27日 19:38
 * @version: V1.0
 */
public class ResultUtil extends BaseResultUtil {
    /**
     * use enum
     *
     * @param status
     * @return
     */
    public static CommonResult returnError(IResultCode status) {
        return returnError(status.getCode(), status.getMessage());
    }

    /**
     * use enum
     *
     * @param status
     * @return
     */
    public static <T> CommonResult returnErrorData(IResultCode status, T data) {
        CommonResult result = new CommonResult();
        result.setCode(status.getCode());
        //result.setData("");
        result.setMessage(status.getMessage());
        result.setData(data);
        return result;
    }

    /**
     * use enum
     *
     * @param status
     * @return
     */
    public static CommonResult returnError(IResultCode status, String description) {
        return returnError(status.getCode(), status.getMessage(), description);
    }
}
